import traceback
import os
os.environ["HF_ENDPOINT"]="https://hf-mirror.com"

from others.neuttsAirMain.neuttsair.neutts import NeuTTSAir


def donwloadModel():
    print("##### 下载 neuttair 模型 #######")
    try:
        tts = NeuTTSAir(backbone_repo="neuphonic/neutts-air-q4-gguf", backbone_device='cpu',
                        codec_repo="neuphonic/neucodec", codec_device='cpu')
        tts.codec
    except Exception as e :
        traceback.print_exc()
    finally:
        try:
            if tts:
                if tts.backbone:
                    tts.backbone.close()
        except Exception as e :
            traceback.print_exc()

    try:
        from huggingface_hub import delete_cache
        delete_cache()
    except Exception as e:
        traceback.print_exc()

donwloadModel()